package com.jz.community.moduleshoppingguide.neighbor.ui.adapter;

import android.content.Context;
import android.content.Intent;
import android.widget.TextView;

import com.gongwen.marqueen.MarqueeFactory;
import com.jz.community.basecomm.base.BaseX5WebActivity;
import com.jz.community.basecomm.utils.Preconditions;
import com.jz.community.moduleshoppingguide.neighbor.bean.CircleNoticeBean;


/**
 * Created by Andy Huang on 2018/4/25.
 *
 * @description:
 */
public class NoticeViewMF extends MarqueeFactory<TextView, CircleNoticeBean.EmbeddedBean.ContentBean> {


    public NoticeViewMF(Context mContext) {
        super(mContext);

    }

    @Override
    protected TextView generateMarqueeItemView(CircleNoticeBean.EmbeddedBean.ContentBean data) {
        TextView mView = new TextView(mContext);
        mView.setText(data.getTitle());
        mView.setOnClickListener(v -> {
            Intent intent = new Intent(mContext, BaseX5WebActivity.class);
            intent.putExtra("title", data.getTitle());
            if (!Preconditions.isNullOrEmpty(data.get_links()) && !Preconditions.isNullOrEmpty(data.get_links().getContent())) {
                intent.putExtra("url", data.get_links().getContent().getHref());
            }
            mContext.startActivity(intent);
        });
        return mView;
    }
}
